<template>
  <div>
    <Header></Header>
    <div class="list_bg">
      <GoodList class="list_section" :list="list" @handleDetail="toDetail"></GoodList>
    </div>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNo" :limit.sync="listQuery.pageSize"
      @pagination="getList" />
    <Footer></Footer>
  </div>
</template>

<script>
import {
  getAgentGoodList
} from "@/api/front-home.js";
import Footer from "@/views/front/components/Footer";
import Header from "@/views/front/components/Header";
import Pagination from "@/views/front/components/Pagination";
import GoodList from "@/views/front/shop/components/GoodList";

export default {
  name: "AgentGoodList",
  props: {

  },
  components: {
    Footer,
    Header,
    Pagination,
    GoodList
  },
  data() {
    return {
      list: [],
      total: 0,
      listQuery: {
        proxyBrandId: '',
        gongyingId: 48244,
        isSeckill: 2,
        pageNo: 1,
        pageSize: 20,
      },
    }
  },
  computed: {

  },
  watch: {},
  methods: {
    getList() {
      getAgentGoodList(this.listQuery).then(res => {
        this.list = res.list || []
        this.total = res.totalCount
      })
      .catch((err) => {
        
      })
    },
    toDetail(goodItem) {
        //新建窗口打开
        const { href } = this.$router.resolve({
          path: "/front-shop/productDetail",
          query: {
            id: goodItem.gongyingId,
            productId: goodItem.id
          }
        });
        window.open(href, '_blank');
      }
  },
  created() {
    this.listQuery.proxyBrandId = this.$route.query.id
    this.getList()
  },
  mounted() {
    
  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='scss' scoped>
  .list_bg {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;

    .list_section {
      position: relative;
      width: 1200px;
    }
  }
</style>